package com.kly.cashmall.module.order.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kly.cashmall.R;
import com.kly.cashmall.bean.LoanListItemBean;
import com.kly.cashmall.utils.function.GlideUtils;
import com.kly.cashmall.utils.data.TextUtil;


/**
 * @author
 */
public class LoanListAdapter extends BaseQuickAdapter<LoanListItemBean, BaseViewHolder> {
  public LoanListAdapter() {
    super(R.layout.item_company_order_layout);
  }

  @Override
  protected void convert(@NonNull BaseViewHolder holder, LoanListItemBean bean) {
    if (!TextUtil.isEmpty(bean.getCategoryLogo())){
      GlideUtils.loadImage(getContext(),bean.getCategoryLogo(),holder.getView(R.id.item_order_icon));
    }
    holder.setText(R.id.item_order_title,bean.categoryName);
    holder.setText(R.id.item_order_date,bean.applyDate);
    holder.setText(R.id.item_order_loan_amount,bean.amount);
    holder.setText(R.id.item_order_duration_size,bean.duration);
    holder.setText(R.id.item_order_status,bean.statusText+" >>");
    holder.setBackgroundResource(R.id.item_order_status,bean.status == 4 ? R.drawable.shape_order_status_refused:
            bean.status == 0 ? R.drawable.shape_order_status_completed :
                    bean.status == 3? R.drawable.shape_order_status_waiting:
            bean.status == 1 ? R.drawable.shape_order_status_reviewing : R.drawable.shape_order_status_overdue);
    if (getItemCount() == holder.getAdapterPosition()+1){
      holder.setVisible(R.id.item_order_line,false);
    }else {
      holder.setVisible(R.id.item_order_line,true);
    }
  }
}
